{extend name="template/base" /}
{block name="style"}
<!--select2样式 start -->
<link href="__LIB__/select2-4.0.3/dist/css/select2.min.css" rel="stylesheet" />
<!--select2样式 end -->
{/block}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="id" value="{$vo.id ?? ''}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">标题：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="标题" name="title" value="{$vo.title ?? ''}" >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">客人数量：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="数量" name="num" value="{$vo.num ?? ''}" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">用车形式：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <select name="car_form" class="select"  id="car_form">
                    <option value="">选择用车形式</option>
                    <option value="拼车" {eq name="vo.car_form" value="拼车"} selected = "selected" {/eq} >拼车</option>
                    <option value="包车"  {eq name="vo.car_form" value="包车"} selected = "selected" {/eq}>包车</option>
                    <option value="定制"  {eq name="vo.car_form" value="定制"} selected = "selected" {/eq}>定制</option>
                    <option value="深度游"  {eq name="vo.car_form" value="深度游"} selected = "selected" {/eq}>深度游</option>
                </select>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">车型：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <select name="car_type_id" class="select"  id="car_type_id">
                    <option value="">选择车型</option>
                    {volist name="car_types" id="car_type"}
                    <option value="{$car_type['id']}"  >{$car_type['id']}：{$car_type['car_type']}：{$car_type['seating']}{$car_type['seating']<$car_type['max_seating']?"-".$car_type['max_seating']:""}</option>
                    {/volist}
                </select>

            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>



        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">出发时间：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" autocomplete="off" class="input-text Wdate go_date" onchange="end_date_change(this)" style="width:250px" placeholder="出发时间" name="go_date" value="{$vo.go_date ?date('Y-m-d',$vo['go_date']): ''}" {literal} onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'})" {/literal} >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>


        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">结束时间：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text Wdate end_date" autocomplete="off" style="width:250px" placeholder="结束时间" name="end_date" value="{$vo.end_date ?date('Y-m-d',$vo['end_date']):''}" {literal} onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'})" {/literal} >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">备注：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <textarea  name="remark" class="textarea">{$vo.remark ?? ''}</textarea>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <div id="content"></div>
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}

<!--时间插件-->
<script type="text/javascript" src="__LIB__/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="__LIB__/template/template.js"></script>
<!--select2 js 插件-->
<script type="text/javascript" src="__LIB__/select2-4.0.3/dist/js/select2.min.js"></script>
<script>
    function end_date_change(e) {
        var day = parseInt('{$day}');
        if(day == '' || typeof day == undefined || day == null){
            layer.msg('该行程无行程天数，无法计算结束日期', {
                time: 1500 //2秒关闭（如果不配置，默认是3秒）
            });
            return false;
        }
        var go_date_val = $('.go_date').val();
        if(go_date_val == '' || typeof go_date_val == undefined || go_date_val == null){
            layer.msg('出发日期为空，无法计算结束日期', {
                time: 1500 //2秒关闭（如果不配置，默认是3秒）
            });
            return false;
        }

        var go_date_arr = go_date_val.split('-');
        var go_date = new Date(go_date_arr[0],go_date_arr[1] -1,go_date_arr[2]);

        go_date.setDate(go_date.getDate()+day);//获取AddDayCount天后的日期
        var y = go_date.getFullYear();
        var m = go_date.getMonth()+1;//获取当前月份的日期
        m = m < 10 ? ('0' + m) : m;
        var d = go_date.getDate();
        d = d < 10 ? ('0' + d) : d;
        $('.end_date').val(end_date)
    }
    $(function () {

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        //车型select2 js部分 start
        var car_type_id = $("#car_type_id").select2({
            language: "zh-CN", //设置 提示语言
            width: "100%", //设置下拉框的宽度
            theme: "classic"
        });
        {notempty name = "vo['car_type_id']"}
        car_type_id.val("{$vo['car_type_id']}").trigger("change");
        {/notempty}
            //车型select2 js部分 end

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret){
                if(ret.code == 0){
                    layer.msg(ret.msg, {
                        icon: 1,
                        time: 1500 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                        window.parent.location.reload(); //刷新父页面
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引\
                        parent.layer.close(index)
                    });
                }else{
                    ajax_progress(ret);
                }
            }
        });
    })
</script>
{/block}
